home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / Pedestal / Source / Sources / Tasks / PedAgent.cc next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  1.1 KB  |  73 lines

  1. /* PedAgent.cc */
  2.  
  3. #include "PedAgent.hh"
  4. #include "PedWindow.hh"
  5.  
  6. PedAgent::PedAgent(PedTask *inParent)
  7. : PedTask(inParent), mWindow(NULL), mPersistent(false)
  8. {
  9. }
  10.  
  11. PedAgent::~PedAgent()
  12. {
  13.     if (mWindow)
  14.         mWindow->release();
  15. }
  16.  
  17. void
  18. PedAgent::InitWindow()
  19. {
  20.     if (!mWindow) {
  21.         // Note that at the moment, PedWindow() calls SetWindow(),
  22.         // which sets mWindow, so this is redundant (but harmless).
  23.         mWindow = new PedWindow(this);
  24.         // Counterbalance the implicit retain.  (SetWindow will retain for us.)
  25.         mWindow->release();
  26.         //PedPaneTE *pane = new PedPaneTE(*mWindow);
  27.         //mWindow->SetPane(pane);
  28.     }
  29. }
  30.  
  31. PedWindow *
  32. PedAgent::Window()
  33. {
  34.     return mWindow;
  35. }
  36.  
  37. void
  38. PedAgent::SetWindow(PedWindow *inWindow)
  39. {
  40.     if (inWindow)
  41.         inWindow->retain();
  42.     PedWindow *oldWindow = mWindow;
  43.     mWindow = inWindow;
  44.     if (oldWindow)
  45.         oldWindow->release();
  46. }
  47.  
  48. bool
  49. PedAgent::OpenWindow()
  50. {
  51.     if (!mWindow)
  52.         InitWindow();
  53.     mWindow->Open();
  54.     return true;
  55. }
  56.  
  57. bool
  58. PedAgent::CloseWindow()
  59. {
  60.     if (mWindow) {
  61.         if (mPersistent) {
  62.             mWindow->Close();
  63.         } else {
  64.             retain();
  65.             mWindow->Dispose();
  66.             mWindow->release();
  67.             mWindow = NULL;
  68.             release();
  69.         }
  70.     }
  71.     return true;
  72. }
  73.